package pub.guoxin.oops.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.http.HttpStatus;

/**
 * Created by guoxin on 17-10-18.
 */
@Data
@ApiModel("返回对象")
public class ResultVo<T> {
    @ApiModelProperty(value = "状态码")
    private int code;
    @ApiModelProperty(value = "信息")
    private String msg;
    @ApiModelProperty(value = "数据")
    private T data;

    public ResultVo(int code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public ResultVo(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public ResultVo(HttpStatus resultCode, T data) {
        this.msg = resultCode.getReasonPhrase();
        this.code = resultCode.value();
        this.data = data;
    }

}
